let mongoose = require('mongoose');
let config  = require('./index');

let connection =mongoose.connect(config.mongo,{
    useNewUrlParser:true,
    useUnifiedTopology:true
});
// let connection = mongoose.createConnection("mongodb://127.0.0.1/zfpx",
// { useNewUrlParser: true,useUnifiedTopology: true});
console.log(connection,'connection');
connection.on('error', function (error) {
    console.log('数据库连接失败: ' + error);
});
connection.on('open', function (error) {
    console.log('数据库连接成功');
});

// module.exports =  mongoose;
module.exports =  connection;
